﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using ApiManage.Core.Repository.MongoDB;
using ApiManage.Models.MongoMappings.Project;
using Rhonin.Common.Components;

namespace ApiManage.Service.Mongo.Project.Impl
{
    [Component(LifeStyle.Singleton)]
    public class InterfaceInfoQueryService : IInterfaceInfoQueryService
    {
        private readonly IProjectRepository<InterfaceInfo> _interfaceInfoRepository;
        public InterfaceInfoQueryService(IProjectRepository<InterfaceInfo> interfaceInfoRepository)
        {
            _interfaceInfoRepository = interfaceInfoRepository;
        }

        public InterfaceInfo Get(Expression<Func<InterfaceInfo, bool>> where)
        {
            return _interfaceInfoRepository.GetQuery().FirstOrDefault(where);
        }

        public List<InterfaceInfo> GetList(Expression<Func<InterfaceInfo, bool>> where)
        {
            return _interfaceInfoRepository.GetQuery().Where(where).ToList();
        }
    }
}
